#pragma once

namespace Core_Common {

	template<typename T>
	class Singleton 
	{
	public:
		static bool HasInstance() 
		{
			return (instance!=NULL);
		}

		static T* GetInstance() 
		{
			myassert(instance);
			return instance;
		}

		static void NewInstance() 
		{
			myassert(instance==NULL);
			if(instance)
				delete instance;
			instance = new T();
		}

		static void DeleteInstance() 
		{
			myassert(instance);
			if(instance)
				delete instance;
			instance = NULL;
		}

	protected:
		static T* instance;
	};

	template<typename T>
	T* Singleton<T>::instance = NULL;

} // namespace_end
